package com.cloud.sysmana.entity.dao.impl;

import java.util.List;

import com.cloud.sysmana.entity.SysRoleFunc;
import com.cloud.sysmana.entity.dao.ISysRoleFuncDao;
import com.cloud.util.base.BaseHibernateDao;

/**
 * 岗位功能Dao
 * @author gaof
 * @date 2016年5月5日
 */
public class SysRoleFuncDao extends BaseHibernateDao<SysRoleFunc, Integer> implements ISysRoleFuncDao {

	/**
	 * 通过岗位id获取岗位功能
	 * @param id
	 * @return
	 */
	@Override
	public List<SysRoleFunc> getRoleFuncByRoleId(Integer id) {
		return getEntities("FROM SysRoleFunc WHERE id.roleId = " + id);
	}

	/**
	 * 删除岗位所有权限
	 * @param roleId
	 */
	@Override
	public void delRoleFuncByRoleId(int roleId) {
		this.executeQuery("delete from sys_role_func where role_id = " + roleId);
	}

	/**
	 * 批量添加岗位权限
	 * @param roleFuncList
	 */
	@Override
	public void saveRoleFuncs(List<SysRoleFunc> roleFuncList) {
		this.saveEntities(roleFuncList);
	}

	/**
	 * 通过功能id删除授权
	 * @param id
	 */
	@Override
	public void delRoleFuncByFuncId(Integer id) {
		this.executeQuery("delete from sys_role_func where func_id = " + id);
	}
	
}
